package online.hxstart.code.concurrent.chapter06;

import java.util.concurrent.TimeUnit;

/**
 * @author huxing
 * @date 19-5-31 星期五 下午5:42
 * @describe
 */
public class ThreadGroupInterrupt {

  public static void main(String[] args) throws InterruptedException {
    ThreadGroup group = new ThreadGroup("TestGroup");

    new Thread(group, () -> {
      while (true) {
        try {
          TimeUnit.MILLISECONDS.sleep(2);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }, "t1").start();

    new Thread(group, () -> {
      while (true) {
        try {
          TimeUnit.MILLISECONDS.sleep(1);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }, "t2");

    TimeUnit.MILLISECONDS.sleep(2);
    group.interrupt();
  }

}
